//
//  LS_Textfield.m
//  breadPro
//
//  Created by 刘文超 on 2019/7/6.
//  Copyright © 2019 刘文超. All rights reserved.
//

#import "LS_Textfield.h"

@implementation LS_Textfield
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.placeholder = @"搜索内容、地点、用户";
        self.layer.cornerRadius = 15.0;
        self.layer.masksToBounds = YES;
        self.backgroundColor = LS_SetColor(65, 170, 184);
        self.layer.borderColor =LS_SetColor(65, 170, 184).CGColor;
        self.layer.borderWidth = 1;
        self.font = LS_FontWithname(@"DamascusLight", 13);
        self.textColor = [UIColor whiteColor];
        [self setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
        
    }return self;
}

/**
 修改文本展示区域
 */
-(CGRect)textRectForBounds:(CGRect)bounds
{
  
    return CGRectMake(bounds.origin.x + 20, bounds.origin.y + 5, bounds.size.width - 20, bounds.size.height);
}

/**
  重写编辑区域，可以改变光标起始位置，以及光标最右到什么地方，placeHolder的位置也会改变

 */
-(CGRect)editingRectForBounds:(CGRect)bounds
{
    return CGRectMake(bounds.origin.x + 20, bounds.origin.y + 3, bounds.size.width - 20, bounds.size.height);
}
@end
